package net.wicp.tams.commons.binlog.replication;

import java.io.IOException;

import net.wicp.tams.commons.apiext.ByteUtil.AssitRead;
import net.wicp.tams.commons.binlog.bean.PacketBean;

public abstract class AbsPacketRead implements IPacketRead {
	private static final long serialVersionUID = 1L;
	protected final PacketBean packetBean;

	public AbsPacketRead(PacketBean packetBean) {
		this.packetBean = packetBean;
		try {
			AssitRead reader=new AssitRead(packetBean.getBody());
			readBody(reader);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	protected abstract void readBody(AssitRead reader) throws IOException;


	@Override
	public int getLength() {
		return packetBean.getLength();
	}

	@Override
	public int getSequence() {
		return packetBean.getSequence();
	}

}
